<script setup lang="ts">
import { ref } from 'vue'

const isShow = ref(true)
const toggle = () => {
  isShow.value = !isShow.value
}
</script>


<template>
  <button @click="toggle">控制显示和隐藏</button>
  <div class="box" v-show="isShow" @click="toggle">我是v-show控制的盒子</div>
  <div class="box" v-if="isShow" @click="toggle">我是v-if控制的盒子</div>
</template>

<style>
.box {
  width: 100px;
  height: 100px;
  background-color: red;
  margin-bottom: 20px;
}
</style>
